﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Zeta;
using Zeta.Common;
using Zeta.Internals.Actors;

namespace UltimatePlugin.Db.Cache
{
    internal abstract class CachedObject
    {
        protected CachedObject(DiaObject diaObject, CachedType type)
        {
            if (diaObject == null)
            {
                throw new ArgumentNullException();
            }
            AcdGuid = diaObject.ACDGuid;
            AcdObject = diaObject.CommonData;
            CachedType = type;
            InternalDiaObject = diaObject;
            SNOId = diaObject.ActorSNO;
        }

        public int SNOId
        {
            get;
            set;
        }

        public float CentreDistance
        {
            get;
            set;
        }

        public SNOAnim CurrentAnimation 
        { 
            get; 
            set; 
        }

        public int DynamicId 
        { 
            get; 
            set; 
        }

        public DiaObject InternalDiaObject
        {
            get;
            private set;
        }

        public Vector3 Position
        {
            get;
            set;
        }

        public bool IsAttackable
        {
            get;
            set;
        }

        public DateTime LastRefreshDate 
        { 
            get; 
            set; 
        }

        public ACD AcdObject
        {
            get;
            private set;
        }

        public int AcdGuid
        {
            get;
            private set;
        }

        public CachedType CachedType 
        { 
            get; 
            private set; 
        }

        public DateTime LastAccessDate 
        { 
            get; 
            set; 
        }

        internal abstract CachedObject Clone();

        public override bool Equals(object obj)
        {
            if (obj is CachedObject)
            {
                return ((CachedObject)obj).AcdGuid == this.AcdGuid;
            }
            else
                return false;
        }

        public override string ToString()
        {
            return string.Format("ACDGuid : {0}", AcdGuid);
        }

        public override int GetHashCode()
        {
            return ToString().GetHashCode();
        }
    }
}
